<?php 

function haveAccess($page){
	switch ($_SESSION['group']){

	case 'SYSADMIN':
		return true;
		break;

	case 'BUSAGENT':
		return !(($page == "reports") || ($page == "stats"));
		break;

	case 'FINCONTR':
		return !(($page == "reports") || ($page == "stats") || ($page == "advertisement-list"));
		break;
	case 'REGUSER':
		return !(($page == "reports") || ($page == "stats") || ($page == "advertisement-list") || ($page == "transactions"));
		break;

	case 'Guest':
		return (($page == "search") || ($page == "ads") || ($page == "password") || ($page == "registration"));
		break;

	default:
		return false;
	}
}

function echoLink($page, $pageName){
	if(haveAccess($page)){
		echo('<a href="?page='.$page.'">'.$pageName.'</a><br/>');
	}
}

?>
